(require 'planner)
(define-key planner-mode-map (kbd "C-c c t") 'planner-create-task)
(define-key planner-mode-map (kbd "C-c c n") 'planner-create-note)
(define-key planner-mode-map (kbd "C-c g i") 'planner-index)
(define-key planner-mode-map (kbd "C-c c s") 'inputSchedule)
(define-key planner-mode-map (kbd "C->") 'planner-goto-next-daily-page)
(define-key planner-mode-map (kbd "C-<") 'planner-goto-previous-daily-page)
(define-key planner-mode-map (kbd "C-.") 'planner-goto-today)
(define-key planner-mode-map (kbd "C-,") 'tiw-init-schedule)
;; initialize schedule
(add-hook 'planner-mode-hook 'tiw-init-schedule)
(add-hook 'planner-mode-hook 'tiw-init-planner)
(require 'remember)

;; remember-planner - a must have...
(require 'remember-planner)
(setq remember-handler-functions '(remember-planner-append))
(setq remember-annotation-functions planner-annotation-functions)
(require 'planner-gnus)
(planner-gnus-insinuate)
;;(require 'planner-bbdb)

(require 'planner-diary)
(setq planner-diary-use-diary t)
(planner-insinuate-diary)
(planner-insinuate-calendar)
(setq planner-diary-number-of-days 7)
(setq planner-diary-number-of-diary-entries 7)
(setq planner-diary-file diary-file)

(defun planner-diary-add-entry (date time text)
    "Prompt for a diary entry to add to `diary-file'.  Will run
    planner-annotations to make hyper links"
    (interactive (list (planner-read-date)
  		     (read-string "Time: ")
                     (read-string "Diary entry: ")))
    (save-excursion
      (save-window-excursion
        (make-diary-entry
         (concat
          (let ((cal-date (planner-filename-to-calendar-date date)))
            (if european-calendar-style
                (format "%d/%d/%d"
                        (elt cal-date 1)
                        (elt cal-date 0)
                        (elt cal-date 2))
              (format "%d/%d/%d"
                      (elt cal-date 0)
                      (elt cal-date 1)
                      (elt cal-date 2))))
          " " time " " text " "
          (run-hook-with-args-until-success
           'planner-annotation-functions))))))

   (define-key global-map [?\C-x ?\C-d] 'planner-diary-add-entry)

